<template>
	<view class="content">
		<!-- <view class="item" @click="bindPhone">
			<view class="left">
				<image src="../../static/s-1.png" mode="widthFix"></image>
				<text v-if="userData">{{userData.phone}}</text>
			</view>
			<view class="right">
				<text>更换手机号</text>
				<image src="/static/rihgt-999.png" mode=""></image>
			</view>
		</view> -->
		<view class="item" @click="bindJY">
			<view class="left">
				<image src="../../static/s-2.png" mode="widthFix"></image>
				<text>交易密码</text>
			</view>
			<view class="right">
				<text>设置</text>
				<image src="/static/rihgt-999.png" mode=""></image>
			</view>
		</view>
		<view class="item" @click="bindLogin">
			<view class="left">
				<image src="../../static/s-3.png" mode="widthFix"></image>
				<text>登录密码</text>
			</view>
			<view class="right">
				<text>设置</text>
				<image src="/static/rihgt-999.png" mode=""></image>
			</view>
		</view>
		<view class="item" @click="bindTrc20">
			<view class="left">
				<image src="../../static/s-4.png" mode="widthFix"></image>
				<text>提币地址（TRC20）</text>
			</view>
			<view class="right">
				<text>设置</text>
				<image src="/static/rihgt-999.png" mode=""></image>
			</view>
		</view>
		<!-- <view class="item" @click="bindBank">
			<view class="left">
				<image src="../../static/s-5.png" mode="widthFix"></image>
				<text>银行信息</text>
			</view>
			<view class="right">
				<text>设置</text>
				<image src="/static/rihgt-999.png" mode=""></image>
			</view>
		</view> -->
	</view>
	<button class="secure-btn" @click="bindLogout">退出登录</button>
</template>

<script setup>
	import {
		userLogout,
		user
	} from '@/util/api.js'
	import {
		ref
	} from "vue";
	import {
		onShow
	} from '@dcloudio/uni-app'
	onShow(()=>{
		getUser()
	})
	const userData = ref()
	// 获取当前登录用户信息
	const getUser = async () => {
		const result = await user()
		console.log(result)
		if (result.code == 200) {
			result.data.phone = result.data.mobile.slice(0,3)+'****'+result.data.mobile.slice(7,11)
			
			userData.value = result.data
		} else {
			userData.value = null
		}
	}
	const bindTrc20 = () => {
		uni.navigateTo({
			url: "/pages/trc20/trc20"
		})
	}
	const bindBank = () => {
		uni.navigateTo({
			url: "/pages/bank/bank"
		})
	}
	const bindLogin = () => {
		uni.navigateTo({
			url: "/pages/setLoginPassword/setLoginPassword"
		})
	}
	const bindJY = () => {
		uni.navigateTo({
			url: "/pages/setJYPassword/setJYPassword"
		})
	}
	const bindPhone = () => {
		uni.navigateTo({
			url: "/pages/setPhone/setPhone"
		})
	}
	const bindLogout = () => {
		uni.showModal({
			title: "提示",
			content: "是否退出登录",
			success: async (ret) => {
				if (ret.confirm) {
					await userLogout()
					uni.clearStorage()
					uni.switchTab({
						url: "/pages/index/index"
					})
				}
			}
		})
	}
</script>

<style lang="scss">
	.secure-btn {
		color: #fff;
		font-size: 38rpx;
		font-weight: 800;
		width: 673rpx;
		height: 100rpx;
		background: #0265FF;
		box-shadow: 0px 12rpx 38rpx 2rpx rgba(0, 4, 61, 0.12);
		border-radius: 71rpx;
		margin: 65rpx auto 0;
		line-height: 100rpx;
		border: none;
	}

	.content {
		margin: 38rpx;
		background: #FFFFFF;
		box-shadow: 0px 15rpx 38rpx 2rpx rgba(49, 54, 70, 0.05);
		border-radius: 23rpx;

		.item {
			height: 110rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 38rpx;

			.left {
				display: flex;
				align-items: center;

				image {
					display: block;
					width: 30rpx;
					margin-right: 6rpx;
				}

				text {
					color: #333333;
					font-size: 30rpx;
					display: block;
				}
			}

			.right {
				display: flex;
				align-items: center;

				text {
					display: block;
					color: #999;
					font-size: 30rpx;
				}

				image {
					width: 38rpx;
					height: 38rpx;
					display: block;
				}
			}
		}
	}

	page {
		background: #F6F7F9;
	}
</style>